import { createRouter, createWebHashHistory } from 'vue-router';
import SingleHeaderSkeleton from "/src/components/single-header/SingleHeaderSkeleton.vue";
import HomeView from "/src/views/home-views/home-view/HomeView.vue";
import HeaderSidebarSkeleton from "/src/components/header-sidebar/HeaderSidebarSkeleton.vue";
import PaperView from "/src/views/entity-views/paper-view/PaperView.vue";
import ScholarView from "/src/views/entity-views/scholar-view/ScholarView.vue";
import VenueView from "/src/views/entity-views/venue-view/VenueView.vue";
import ConceptView from "/src/views/entity-views/concept-view/ConceptView.vue";
import refresh from "/src/views/entity-views/concept-view/refresh.vue";
import OrgView from "/src/views/entity-views/org-view/OrgView.vue";
import LoginView from "/src/views/account-views/LoginView.vue";
import RegisterView from "/src/views/account-views/RegisterView.vue";
import ChangePwdView from "/src/views/account-views/ChangePwdView.vue";
import AccountInfoView from "/src/views/account-manage-views/account-info-view/AccountInfoView.vue";
import StarPaperView from "/src/views/account-manage-views/star-paper-view/StarPaperView.vue";
import StarScholarView from "/src/views/account-manage-views/star-scholar-view/StarScholarView.vue";
import AdminReviewClaimView from "/src/views/admin-views/admin-review-claim-view/AdminReviewClaimView.vue";
import SearchView from "/src/views/search-view/SearchView.vue";
import AccountSkeleton from "../views/skeletons/AccountSkeleton.vue";
import AdminSkeleton from "../views/skeletons/AdminSkeleton.vue";
import MainSkeleton from "../views/skeletons/MainSkeleton.vue";
import AboutView from "../views/home-views/about-view/AboutView.vue";
import AdminRegisterView from "../views/admin-views/admin-register-view/AdminRegisterView.vue";
// import ScholarStatic  from "/src/views/entity-views/scholar-view/ScholarStatic.vue"

const routes = [{
        path: '/',
        redirect: '/home',
    },
    // 以下路由的页面只含有单个导航栏
    {
        path: '/',
        name: 'single-header-skeleton',
        component: MainSkeleton,
        children: [
            {
                path: '/home',
                name: 'home',
                component: HomeView,
            },
            {
                path: '/about',
                name: 'about',
                component: AboutView,
            },
            {
                path: '/scholar/:scholar_id?',
                name: 'scholar',
                component: ScholarView,
                props: true,
                beforeEnter: (to, from, next) => {
                    to.params.scholar_id = to.params.scholar_id || 'A5003086136';
                    next();
                },
            },
            /*
            {
                path: '/scholar_static/:scholar_id?',
                name: 'scholar_static',
                component: ScholarStatic,
                props: true,
                beforeEnter: (to, from, next) => {
                    to.params.scholar_id = to.params.scholar_id || 'A5003086136';
                    next();
                },
            },*/
            {
                path: '/paper/:paper_id?',
                name: 'paper',
                component: PaperView,
                props: true,
                beforeEnter: (to, from, next) => {
                    to.params.paper_id = to.params.paper_id || 'W2131350133';
                    next();
                },
            },
            {
                path: '/venue/:venue_id?',
                name: 'venue',
                component: VenueView,
                props: true,
                beforeEnter: (to, from, next) => {
                    // 如果没有提供 venue_id 参数，有默认
                    to.params.venue_id = to.params.venue_id || 'S137773608';
                    next();
                },
            },
            {
                path: '/org/:org_id?',
                name: 'org',
                component: OrgView,
                props: true,
                beforeEnter: (to, from, next) => {
                    to.params.org_id = to.params.org_id || 'I4210087817';
                    next();
                },
            },
            {
                path: '/concept/:concept_id?',
                name: 'concept',
                component: ConceptView,
                props: true,
                beforeEnter: (to, from, next) => {
                    to.params.concept_id = to.params.concept_id || 'C41008148';
                    next();
                },
            },
            {
                path: '/refresh',
                name: 'refresh',
                component: refresh,
            },
            {
                path: '/login',
                name: 'login',
                component: LoginView,
            },
            {
                path: '/register',
                name: 'register',
                component: RegisterView,
            },
            {
                path: '/changepwd',
                name: 'change-pwd',
                component: ChangePwdView,
            },
            {
                path: '/search',
                name: 'search',
                component: SearchView,
            }
        ]
    },
    // 以下路由的页面含有导航栏和侧边栏
    {
        path: '/account',
        redirect: '/account/info',
    },
    {
        path: '/account',
        name: 'account-skeleton',
        component: AccountSkeleton,
        children: [{
                path: '/account/info',
                name: 'account-info',
                component: AccountInfoView,
            },
            {
                path: '/account/star/paper',
                name: 'star-paper',
                component: StarPaperView,
            },
            {
                path: '/account/star/scholar',
                name: 'star-scholar',
                component: StarScholarView,
            }
        ]
    },
    // 以下路由的页面含有导航栏和侧边栏
    {
        path: '/admin',
        redirect: '/admin/reviewclaim',
    },
    {
        path: '/admin',
        name: 'admin-skeleton',
        component: AdminSkeleton,
        children: [
            {
                path: '/admin/reviewclaim',
                name: 'review-claim',
                component: AdminReviewClaimView,
            },
            {
                path: '/admin/register',
                name: 'admin-register',
                component: AdminRegisterView,
            }
        ]
    }
];

const router = createRouter({
    history: createWebHashHistory(),
    routes,
});

export default router;